home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 5791 / 5791.xpi / chrome / flagfox.jar / content / preview.xul < prev    next >
Extensible Markup Language  |  2008-09-13  |  4KB  |  90 lines

  1. <?xml version="1.0"?>
  2.  
  3. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  4. <?xml-stylesheet href="chrome://flagfox/content/style.css" type="text/css"?>
  5.  
  6. <!DOCTYPE window SYSTEM "chrome://flagfox/locale/flagfox.dtd">
  7.  
  8. <window class="dialog"
  9.         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  10.         orient="vertical"
  11.         autostretch="always"
  12.         onload="generate();"
  13.         title="&prefs.previewicons;">
  14.  
  15.     <keyset>
  16.         <key keycode="VK_ESCAPE" oncommand="window.close();"/>
  17.     </keyset>
  18.  
  19.     <stringbundleset>
  20.         <stringbundle id="flagfox-countrynames" src="chrome://flagfox/locale/countrynames.properties"/>
  21.     </stringbundleset>
  22.  
  23.     <script type="application/x-javascript" src="chrome://flagfox/content/util.js"/>
  24.     <script type="application/x-javascript">
  25.     <![CDATA[
  26.         const FLAGS_PER_ROW = 20;
  27.         const EXCLUDE_PREVIEWS = "-A,-B,-C,-L,A1,A2";
  28.         var countrynames = null;
  29.         function generate()
  30.         {
  31.             try
  32.             {
  33.                 countrynames = document.getElementById("flagfox-countrynames");
  34.                 //var time1 = new Date().getTime();
  35.                 document.getElementById("preview1").appendChild(spawnset("flagset1"));
  36.                 document.getElementById("preview2").appendChild(spawnset("flagset2"));
  37.                 //var time2 = new Date().getTime();
  38.                 //document.getElementById("loadtimer").setAttribute("value",(time2-time1)+"ms");
  39.             }
  40.             catch (e) { Flagfox_error("Failed to generate preview",e); }
  41.         }
  42.         function spawnset(set)
  43.         {
  44.             const srcroot = "chrome://flagfox/content/icons/" + set + "/";
  45.             const nsIPE = Components.interfaces.nsIPropertyElement;
  46.             var setbox = document.createElement("vbox");
  47.             var enumerator = countrynames.strings;
  48.             while (enumerator.hasMoreElements())
  49.             {
  50.                 var linebox = document.createElement("hbox");
  51.                 linebox.setAttribute("width",18*FLAGS_PER_ROW);
  52.                 linebox.setAttribute("height",12);
  53.                 var i=0, country, image;
  54.                 while (i<FLAGS_PER_ROW && enumerator.hasMoreElements())
  55.                 {
  56.                     country = enumerator.getNext().QueryInterface(nsIPE);
  57.                     if (EXCLUDE_PREVIEWS.indexOf(country.key) == -1)
  58.                     {
  59.                         image = document.createElement("image");
  60.                         image.setAttribute("src", srcroot + country.key.toLowerCase() + ".png");
  61.                         image.setAttribute("tooltiptext", country.value);
  62.                         image.setAttribute("onclick", "Flagfox_addTabInCurrentBrowser(Flagfox_getWikipediaSearchURL('" + country.value + "'));" );
  63.                         image.setAttribute("style", "cursor: pointer;");
  64.                         linebox.appendChild(image);
  65.                         ++i;
  66.                     }
  67.                 }
  68.                 setbox.appendChild(linebox);
  69.             }
  70.             return setbox;
  71.         }
  72.     ]]>
  73.     </script>
  74.  
  75.     <groupbox id="preview1">
  76.         <caption label="&prefs.previewset1;"/>
  77.     </groupbox>
  78.     <groupbox id="preview2">
  79.         <caption label="&prefs.previewset2;"/>
  80.     </groupbox>
  81.  
  82.     <hbox>
  83.         <spacer flex="1"/>
  84.         <text id="loadtimer" style="font-style: italic; font-size: smaller;"/>
  85.         <spacer flex="5"/>
  86.         <button label="&close;" oncommand="window.close();" default="true" />
  87.     </hbox>
  88.  
  89. </window>
  90.